<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class LoginController extends Controller
{
    //登录页面
    public function login(){
       return view('login');
    }

    public function login_ok(Request $request){
        $rows = $request->input();
        $user = $rows["user"];
        
        $pwd = $rows["pwd"];
        $row = DB::table("zu_login")->where("username",$user)->first();
    
        if($user != null || $pwd != null){
            //验证用户是否存在
            if($user == $row->username){
                //判断密码是否正确
                if($row->password == $pwd){
                    session(['key' => $row->username]);
                    return 1;
                }else{
                    return 0;
                }
            }else{
                return -1;
            }
            
        }
    }




}

?>